# 设计循环赛日程表
def match(n: int) -> list[list[int]]:
    a = [[0] * (n + 1) for _ in range(n + 1)]
    a[1] = [i for i in range(n + 1)]
    m = 1
    while n > 1:
        n //= 2
        for t in range(1, n + 1):
            for i in range(m + 1, 2 * m + 1):
                for j in range(m + 1, 2 * m + 1):
                    a[i][j+(t-1)*m*2] = a[i-m][j+(t-1)*m*2-m]
                    a[i][j+(t-1)*m*2-m]=a[i-m][j+(t-1)*m*2]
        m*=2
    return a

# main
table = match(8)
print(''.join('\tR%d' % i for i in range(1, 8)))
for r in table[1:]:
    print(''.join('P%d' % r[j] if j == 1 else '\t%d' % r[j] for j in range(1, 9)))
